import Taro from "@tarojs/taro";
import { View } from "@tarojs/components";
import { useEffect,useState } from "react";
import './index.scss'
import {getMyPost} from '../../../api/mode'
import { MyPostCard } from "../../../components";

export default function MyPost(){

const [postInfo,setPostInfo]=useState([])

useEffect(
  ()=>{
    getMyPost(Taro.getStorageSync(`openid`)).then(
      res=>{
        // console.log(res.data.data.positionListByTime);
        setPostInfo(res.data.data.positionListByTime)
      }
    )
  },[])

    let timeInfo=Object.keys(postInfo)
    let positionInfo=Object.values(postInfo)

    console.log(postInfo);

      return(
        <View>
             {  postInfo
                ?
               (timeInfo.map((time,index)=> {
               let position=positionInfo[index]
               return (<MyPostCard key={index} timeInfo={time} positionInfo={position} isDetail={1} />)
               }             
                  
               ))
               :null
            }
        </View>
      )
}